<template>
    <div>
        <el-dialog
            :close-on-click-modal="false"
            :title="dialogTitle"
            :width="dialogWith"
            :top='dialogTop'
            v-if="dialogShow"
            :visible.sync="dialogShow"
            @close="$emit('close')"
            v-dialogDrag>
            <template>
                <layered-map v-bind="$attrs" v-on="$listeners" :data="layerOrFmapMes"></layered-map>
            </template>
        </el-dialog>
    </div>
</template>
<script>

// 分层图
import { getFacsLocation } from '@/api/fcf'
import LayeredMap from './PageModel/LayeredMap'

export default {
    name: 'MultifunctionDialog',
    props: {
        parames: {
            required: true
        }
    },
    components: {
        LayeredMap,
    },
    data() {
        return {
            dialogShow: false,
            dialogTitle: '',
            dialogWith: '50%',
            dialogTop: '10vh',
            layerOrFmapMes:{},  //分层图相关数据
        }
    },
    created() {
        let that = this
        that.checkHasLayeredMap()
    },
    methods: {
        // 检测分层图是否存在
        checkHasLayeredMap() {
            let that = this
            getFacsLocation({
                fcfId: that.parames.fcfId//this.$attrs.parames.fcfId
            }).then((res)=>{
                let data = res.data;
                // markType 标注类型 1分层图 2室内地图 0 没有标注信息
                if( res.status === 200 && data && data.markType != 0){
                    if(data.markType == 1) {
                        that.dialogTitle = '分层图'
                    }else{
                        that.dialogTitle = '室内地图'
                    }
                    if((data.markType == 1&& data.layeredGraphUrl)||(data.markType == 2&& data.orgIndoorInfo) ){
                        // 显示弹框
                        that.dialogShow = true;
                        that.layerOrFmapMes = data;
                    }else{
                        this.$message({
                          message: '暂无标注信息',
                          type: 'warning'
                        });
                        that.dialogShow = false;
                        that.$listeners.close();
                    }
                }else{
                    // 显示弹框
                    this.$message({
                      message: '暂无标注信息',
                      type: 'warning'
                    });
                    that.dialogShow = false;
                    that.$listeners.close();
                }
            });
        }
    }
}
</script>
